//
//  UICatalogReadingViewController.m
//  UICatalogReading
//
//  Created by wu di on 12-8-5.
//  Copyright 2012 UTS. All rights reserved.
//

#import "UICatalogReadingViewController.h"

@implementation UICatalogReadingViewController



/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	[super loadView];
	//UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
	//view.backgroundColor = [UIColor lightGrayColor];  
	
	CGRect frame = CGRectMake(10, 70, 300, 50);
	
	//be careful to use initwithframe
	UIButton *btn =[UIButton buttonWithType:UIButtonTypeRoundedRect];
	btn.frame = frame;
	[btn setTitle:@"Click Me, Please!" forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor clearColor];
	btn.tag = 2000;
	/*
	 action:@selector(btnClick:)
					    ^
	 without : the command will not work.
	 */
	[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
	[self.view addSubview:btn];
	//self.view=view;
//	[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
}

- (void)viewDidLoad
{
	[super viewDidLoad];

}										

- (IBAction) btnClick: (id) sender
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Action invoked!"
													message:@"Button clicked!"
												   delegate:self
										  cancelButtonTitle:@"OK"
										  otherButtonTitles:nil];
    [alert show];
    [alert release];
	
	CGRect frame = CGRectMake(10, 15, 300, 20);
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.textAlignment = UITextAlignmentCenter;
	label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont fontWithName:@"Verdana" size:20];
    label.text = @"This is a label";
	label.tag = 1000;
	
	[self.view addSubview:label];
	[label release];
}



/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
